﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDAL;
using DataMode;
using System.Data;
using System.Security.Cryptography;

namespace DAL
{
   public class UserInfoEdit:IUserInfo
    {
       DataModeDataContext ctx = new DataMode.DataModeDataContext();


       public IQueryable GetUserInfoByName(string username)
       {
           IQueryable<userinfo> userQuery = from user in ctx.userinfo where user.username.Equals(username) select user;
           return userQuery;
       }


       public void UpdateUserInfo(DataMode.userinfo ui,string name)
       {
           var edit = ctx.userinfo.SingleOrDefault<userinfo>(s => s.username == name);

           edit.username = ui.username;
           edit.birthday = ui.birthday;
           edit.cellphone = ui.cellphone;
           edit.email = ui.email;
           edit.sex = ui.sex;
           edit.password = ui.password;

           ctx.SubmitChanges();

           
       }


       

       public userinfo getuserinfo(string name)
       {
           //var edit = ctx.userinfo.SingleOrDefault<userinfo>(s => s.username == name);
           userinfo edit = ctx.userinfo.Single(b => b.username == name);
           
           return edit;

           
       }
       
    }
}
